import fetch from '@/utils/fetch'

export function getDeptInfo(params) {
	return fetch({
	    url: '/uc/v1/mgt/dept/node',
	    method: 'get',
	    params
  	})
}

export function getDeptStaffInfo(deptId, params) {
	return fetch({
	    url: `/uc/v1/mgt/dept/${deptId}/staff`,
	    method: 'get',
	    params
  	})
}

export function getDeptRoleInfo(deptId) {
	return fetch({
	    url: `/uc/v1/mgt/dept/${deptId}/role`,
	    method: 'get'
  	})
}

export function setDeptRoleInfo(deptId, data) {
	return fetch({
	    url: `/uc/v1/mgt/dept/${deptId}/role`,
	    method: 'post',
	    data
  	})
}

export function getDeptDataTree(deptId) {
	return fetch({
	    url: `/uc/v1/mgt/dept/${deptId}/data_tree`,
	    method: 'get'
  	})
}

export function addDept(data) {
	return fetch({
	    url: `/uc/v1/mgt/dept`,
	    method: 'post',
	    data
  	})
}

export function modifyDept(deptId, data) {
	return fetch({
	    url: `/uc/v1/mgt/dept/${deptId}`,
	    method: 'patch',
	    data
  	})
}

export function bindDataTree(deptId, dataTreeId) {
	return fetch({
	    url: `/uc/v1/mgt/dept/${deptId}/data_tree/${dataTreeId}`,
	    method: 'post'
  	})
}

//删除部门
export function deleteDept(dept_id){
	return fetch({
		url:`/uc/v1/mgt/dept/${dept_id}`,
		method:'delete'
	})
}

//解除单员工部门关系
export function unbundDept(staffId){
	return fetch({
		url:`/uc/v1/mgt/staff/dept/${staffId}`,
		method:'delete'
	})
}

//解除部门员工关系
export function unbundRole(dept_id,role_id){
	return fetch({
		url:`/uc/v1/mgt/dept/${dept_id}/role/${role_id}`,
		method:'delete'
	})
}

//删除关联部门和数据树
export function unbundDataTree(dept_id){
	return fetch({
		url:`/uc/v1/mgt/dept/${dept_id}/data_tree`,
		method:"delete"
	})
}